


#ifndef _UDP_H_
#define _UDP_H_

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <errno.h>
#include <pthread.h>
#include <ifaddrs.h>


#define UPD_STATE_HEART		0x0001
#define UPD_STATE_INISET	0x0002
#define UPD_STATE_INIREAD	0x0003
#define UPD_STATE_POWERUP_CH1	0x0004
#define UPD_STATE_POWERUP_CH2	0x0005




#define UDP_DATA_HEAD_0	0x5a
#define UDP_DATA_HEAD_1	0xa5

#define UDP_DATA_HEART	0x00


#ifdef PRINT_OPEN 
#define PRINT_OPEN_UDP	1
#else
#define PRINT_OPEN_UDP	1
#endif

#define BUF_SIZE 4096

struct UdpData			// not need crc, because udp package has add crc 
{
	unsigned char	head[2];
	unsigned short	order;
	unsigned int	len;
	unsigned char	buf[BUF_SIZE];
};

struct HeartData
{
	unsigned char	head[4];
	
};

struct UdpMsg
{
	int		sockfd;
	int		recvlen;
	int		port;
	int		tid;
	struct sockaddr_in server_addr;
	struct sockaddr_in client_addr;	
};

extern void *UdpThread(void *threadid);
static int UpdHeartSend(struct UdpData	*pUdpData);
static int UdpIniSet(struct UdpData *pUdpData);

static int UpdIniSend(struct UdpData *pUdpData);




#endif





